/*! \file RBTreeIterator.inl
 *	\brief 
 *
 *	created:	2010/11/23
 *	created:	23:11:2010   13:18
 *	filename: 	C:\src\tactics-engine\libs\core\impl\RBTreeIterator.inl
 *	file path:	C:\src\tactics-engine\libs\core\impl
 *	file base:	RBTreeIterator
 *	file ext:	inl
 *	author:		Vitalii Trubchaninov
 *				vitalii.trubchaninov@ubisoft.com
 */
#include <core/assert.h>

namespace tt{
namespace core{

namespace impl{

template<typename ValueType>
RBTreeIterator<ValueType>::RBTreeIterator()
: m_node(NULL)
{

}

template<typename ValueType>
RBTreeIterator<ValueType>::RBTreeIterator(Node* node)
: m_node(node)
{
}

template<typename ValueType>
RBTreeIterator<ValueType>& RBTreeIterator<ValueType>::operator++()
{
	ttAssert(m_node);
	m_node = m_node->next();
	return *this;
}

template<typename ValueType>
RBTreeIterator<ValueType> RBTreeIterator<ValueType>::operator++(int)
{
	ttAssert(m_node);
	Self result(*this);
	m_node = m_node->next();
	return result;
}

template<typename ValueType>
RBTreeIterator<ValueType>& RBTreeIterator<ValueType>::operator--()
{
	ttAssert(m_node);
	m_node = m_node->prev();
	return *this;
}

template<typename ValueType>
RBTreeIterator<ValueType> RBTreeIterator<ValueType>::operator--(int)
{
	ttAssert(m_node);
	Self result(*this);
	m_node = m_node->prev();
	return result;
}

template<typename ValueType>
bool RBTreeIterator<ValueType>::operator==( const Self& other ) const
{
	return m_node == other.m_node;
}

template<typename ValueType>
bool RBTreeIterator<ValueType>::operator!=( const Self& other ) const
{
	return m_node != other.m_node;
}

template<typename ValueType>
ValueType& RBTreeIterator<ValueType>::operator*()
{
	ttAssert(m_node);
	return m_node->value;
}

template<typename ValueType>
const ValueType& RBTreeIterator<ValueType>::operator*() const
{
	ttAssert(m_node);
	return m_node->value;
}

template<typename ValueType>
ValueType* RBTreeIterator<ValueType>::operator->()
{
	ttAssert(m_node);
	return &m_node->value;
}

template<typename ValueType>
const ValueType* RBTreeIterator<ValueType>::operator->() const
{
	ttAssert(m_node);
	return &m_node->value;
}

} //namespace impl

} //namespace core
} //namespace tt